import { Injectable, NestInterceptor, ExecutionContext, CallHandler } from "@nestjs/common";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";

@Injectable()
export class EncryptParamInterceptor implements NestInterceptor {
    intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
        return next.handle().pipe(
            map((data) => {
                // 在这里修改响应
                const response = context.switchToHttp().getResponse();
                console.log("response", response);
                response.header("X-Response-Interceptor", "true");
                return { data };
            })
        );
    }
}